Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): midealocal CLI tool #204

Merged
merged 9 commits into from
Jul 9, 2024
Merged

feat(cli): midealocal CLI tool #204

merged 9 commits into from
Jul 9, 2024

Conversation

rokam
Copy link
Contributor

@rokam rokam commented Jul 5, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a CLI tool for interacting with Midea local devices.
    • Added device discovery, message loading, and protocol downloading functionalities to the CLI tool.
    • Configured a Python debugger for easier module discovery and debugging.
    • Added constants for application account and password configuration.
    • Added a console script entry point for the CLI tool.
  • Chores

    • Added midea-local.json to .gitignore.
    • Updated requirements.txt with the platformdirs package.

Copy link
Contributor

coderabbitai bot commented Jul 5, 2024

Walkthrough

The changes introduce a CLI tool to interact with Midea local devices, enabling device discovery, message decoding, and protocol implementation download. Additionally, there's a new Python debugger configuration, constants for authentication, and a new utility package included.

Changes

File Change Summary
.vscode/launch.json Configured Python debugger to use debugpy for the midealocal.cli module.
midealocal/cli.py Introduced functions for discovering devices, loading messages, and downloading protocols.
midealocal/const.py Added constants for app account and password, as well as maximum byte values.
setup.py Added entry point for the midealocal CLI tool.
.gitignore Ignored the midea-local.json file.
requirements.txt Added the platformdirs package.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Device
    participant Cloud
    
    User ->> CLI: Execute Command
    CLI ->> CLI: Parse Arguments
    alt Discover Devices
        CLI ->> Device: Send Discovery Signal
        Device -->> CLI: Return Device Info
    else Load Message
        CLI ->> Device: Send Message
        Device -->> CLI: Confirm Receipt
    else Download Protocol
        CLI ->> Cloud: Request Protocol
        Cloud -->> CLI: Return Protocol Data
    end
    CLI -->> User: Display Result
Loading

Poem

By rabbit's code and gleaming eye,

Midea devices now comply.

With discovery swift and messages clear,

Protocols from the clouds appear.

Through the CLI's command, with ease,

Control your world, a digital breeze.

Enjoy the magic, without a glitch,

As Python and Midea smoothly enrich! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov-commenter
Copy link

codecov-commenter commented Jul 5, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 0% with 98 lines in your changes missing coverage. Please review.

Project coverage is 26.71%. Comparing base (07e3405) to head (9e31e15).

Files Patch % Lines
midealocal/cli.py 0.00% 98 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #204      +/-   ##
==========================================
- Coverage   27.09%   26.71%   -0.38%     
==========================================
  Files          79       80       +1     
  Lines        6891     6989      +98     
==========================================
  Hits         1867     1867              
- Misses       5024     5122      +98     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 246f9c7 and 0a18f11.

Files selected for processing (4)
  • .vscode/launch.json (1 hunks)
  • midealocal/cli.py (1 hunks)
  • midealocal/const.py (1 hunks)
  • setup.py (1 hunks)
Files skipped from review due to trivial changes (3)
  • .vscode/launch.json
  • midealocal/const.py
  • setup.py
Additional comments not posted (4)
midealocal/cli.py (4)

24-34: LGTM!

The _get_keys function is well-implemented and correctly uses aiohttp for asynchronous HTTP requests.


74-94: LGTM!

The _message function is well-implemented and correctly processes messages for devices.


103-173: LGTM!

The main function is well-implemented and correctly sets up the argument parser and subparsers.


176-215: LGTM!

The _run function is well-implemented and correctly sets up logging and handles both coroutine and non-coroutine functions.

midealocal/cli.py Outdated Show resolved Hide resolved
midealocal/cli.py Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0a18f11 and 31c252d.

Files selected for processing (1)
  • midealocal/cli.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • midealocal/cli.py

@chemelli74
Copy link
Member

Why not update/enrich library_test.py that has the same scope ?

@rokam
Copy link
Contributor Author

rokam commented Jul 5, 2024

I want to deprecate library_test and provide a tool to understand better and debug the library.
The library_test provides no real-case use and is just a list of functions to be called.

@chemelli74
Copy link
Member

The library_test provides no real-case use and is just a list of functions to be called.

Actually that's not true.
I use it with users to test login, keys, local connection.
Which are the main pain currently.

For sure is not feature complete and needs more love to test all functions, but so far is already useful.

What we should do is improve the token/key management in the library.

@rokam
Copy link
Contributor Author

rokam commented Jul 6, 2024

So, let's move the functionalities to CLI. After installing the midea-local lib, the user could call midealocal .

The library_test does an overall test, unable to provide options for the user.

@wuwentao
Copy link
Member

wuwentao commented Jul 8, 2024

thanks for add this tools, this should be a useful feature in lib side.
also expect it can decode the raw hex msg, read and decode via source code is really not a good solution, we should check the args one by one ans need more debug effect and time cost.
but it's not a urgent requirement, we can do it one by one in future.

and also add detail comments for future changes and quickly understand the process with different developer.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 31c252d and ad1fd65.

Files selected for processing (1)
  • midealocal/cli.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • midealocal/cli.py

@rokam rokam changed the title feat(cli): cli tool feat(cli): midealocal CLI tool Jul 8, 2024
midealocal/cli.py Show resolved Hide resolved
midealocal/cli.py Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ad1fd65 and d66bdec.

Files selected for processing (4)
  • .gitignore (1 hunks)
  • .vscode/launch.json (1 hunks)
  • midealocal/cli.py (1 hunks)
  • requirements.txt (1 hunks)
Files skipped from review due to trivial changes (2)
  • .gitignore
  • requirements.txt
Files skipped from review as they are similar to previous changes (2)
  • .vscode/launch.json
  • midealocal/cli.py

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d66bdec and 4605879.

Files selected for processing (1)
  • midealocal/cli.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • midealocal/cli.py

@rokam rokam requested a review from chemelli74 July 8, 2024 23:38
@chemelli74
Copy link
Member

Maybe remove library_test in this PR as you want to deprecate it

@rokam rokam merged commit 236e33a into main Jul 9, 2024
8 checks passed
@rokam rokam deleted the features/cli branch July 9, 2024 11:10
@rokam rokam mentioned this pull request Jul 9, 2024
wuwentao pushed a commit that referenced this pull request Jul 10, 2024
🤖 I have created a release *beep* *boop*
---


## [1.3.0](v1.2.0...v1.3.0)
(2024-07-10)


### Features

* **c3:** temperature step as customize
([#209](#209))
([4da6e3e](4da6e3e))
* **cli:** midealocal CLI tool
([#204](#204))
([236e33a](236e33a))


### Bug Fixes

* **device:** capabilities
([#212](#212))
([f7cff37](f7cff37))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
  - Added functionality to customize the temperature step in `c3`.

- **Chores**
  - Updated version number to `1.3.0`.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants